package com.ymatou.iapi.sellertrading.service;

import org.json.JSONObject;

import com.ymatou.query.seller.trading.api.parameter.GetOrderFundDetailBean;
import com.ymatou.query.seller.trading.api.service.GetOrderFundDetailCall;
import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;

public class getorderfundflowCall extends YmatouAutoTestCall{
	
	//获取订单资金明细
	private static String opurl = "/api/orderquery/getorderfundflow";
 
	public getorderfundflowCall() {
		super(EnvSetup.getSystemUrl("sellertrading_iapi"),opurl,"GET","JSON");
	}
	public getorderfundflowCall(int sellerId ,  int orderId , int userId ) {
				
		super(EnvSetup.getSystemUrl("sellertrading_iapi"),opurl + "?sellerid="+sellerId  + "&OrderId="+orderId  +  "&UserId="+userId,"GET","JSON");

	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
		
		
	}

	/**
	 * 测试接口是否正常
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
		try{
			
			new getorderfundflowCall(3383,112505505,4085).callAndGetReturnData();
			JSONObject result = getOrderFundDetail(112505505, true);
			System.out.println("test"+result.toString());
		
				
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
	
	
	/**
	 * 订单资金明细 查询(api.trading.seller.query.ymatou.com/api/Order/GetOrderFundDetail)
	 * @param iOrderId 订单id
	 * @param summary false不展示Summary部分
	 * @throws Exception
	 */
	public static JSONObject getOrderFundDetail(int iOrderId , boolean summary) throws  Exception {
		
		GetOrderFundDetailCall getOrderFundDetailCall = new GetOrderFundDetailCall();
		GetOrderFundDetailBean getOrderFundDetailBean = new GetOrderFundDetailBean();
				
		getOrderFundDetailBean.setOrderId(iOrderId);
		getOrderFundDetailBean.setSummary(summary);
		getOrderFundDetailCall.setData(getOrderFundDetailBean);
		getOrderFundDetailCall.callService();
		
		String dataStr = getOrderFundDetailCall.getReturnData();
		JSONObject result = new JSONObject(dataStr);
		
		return result;		
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
}